home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 October / CHIP Ekim 1996.iso / winbatch / filemenu.mn_ < prev    next >
Text File  |  1995-10-30  |  18KB  |  409 lines

  1.           editor="notepad.exe"    ;Default editor
  2.           ; Common menu for all file types
  3.           ;First figure out where filemenu.dll is installed via registry lookup
  4.       ErrorMode(@OFF)
  5.           wbdir=RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinBatch\CurrentVersion")
  6.           if wbdir==0 
  7.              wbdir=RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinBatch Compiler\CurrentVersion")
  8.           endif
  9.           ErrorMode(@CANCEL)
  10.           if wbdir==0 then Display(5,"Error","Registry entries missing.  Re-install WinBatch")
  11.       homedir=strcat(wbdir,"system\")
  12.  
  13.           ;Next see if WinEdit is lurking about via registry lookup
  14.       ErrorMode(@OFF)
  15.           WinEdit=strcat(RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinEdit\CurrentVersion"),"WinEdit.exe")
  16.           ErrorMode(@CANCEL)
  17.           if WinEdit==0    ;No?  Try path
  18.              WinEdit=FileLocate("WINEDIT.EXE")
  19.              if WinEdit=="" then WinEdit=editor
  20.           endif
  21.  
  22.           inifile=strcat(DirWindows(0),"FileMenu.ini")
  23.           if !FileExist(inifile) then inifile=strcat(homedir,"FileMenu.ini")
  24.           commonmenu="FileMenu for all filetypes.mnw"
  25.           defaultmenu="FileMenu for misc filetypes.mnw"
  26.  
  27. Two Explorers, side by side ; Your dual window file manager
  28.         a=IntControl(31,0,0,0,0)  ;return list of ids of explorer windows
  29.         c=ItemCount(a,@TAB)
  30.         switch c
  31.            case 0
  32.               run("explorer.exe",strcat("/n,/e,",DirGet()))
  33.               while FindWindow("ExploreWClass")==""    ;wait for it to come up
  34.                 Yield
  35.               end while
  36.               ;Fall into case 1
  37.  
  38.            case 1
  39.               run("explorer.exe",strcat("/n,/e,",DirGet()))
  40.               break
  41.            case c       ; 2 or more
  42.               break
  43.         endswitch
  44.         d=1
  45.         while c<2 && d<500
  46.            a=IntControl(31,0,0,0,0)
  47.            c=ItemCount(a,@TAB)
  48.            d=d+1
  49.         endwhile
  50.         if c<2 then exit
  51.         id1=ItemExtract(1,a,@TAB)
  52.         id2=ItemExtract(2,a,@tab)
  53.         WinPlaceSet(@NORMAL,id2,"500 0 1000 900")
  54.         WinShow(id2)
  55.         Yield
  56.         Yield
  57.         WinPlaceSet(@NORMAL,id1,"0 0 500 900")
  58.         WinShow(id1)
  59.      
  60. Open With ... ; Choose an application to view or edit the selected file.
  61.  
  62.  &Browser (binary file viewer)  ; View any file in binary format.
  63.         file = CurrFilePath()
  64.         If !(FileExist(file)) Then file = ""
  65.         Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  66.         Run("browser.exe", FileNameShort(file))     
  67.  &Notepad  ; Modify small plain text files.
  68.         file = CurrFilePath()
  69.         If !(FileExist(file)) Then file = ""
  70.         Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  71.         Run("notepad.exe", file)
  72.  &MSPaint (bitmap) ; View and Modify bitmaps
  73.          file = CurrFilePath()
  74.          If !(FileExist(file)) Then file = ""
  75.               Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  76.          bmpfile = FileExtension(file)
  77.          If bmpfile != ".bmp"
  78.               Message("Error","Select a bitmap file and try again.")
  79.               Exit
  80.          EndIf          
  81.          rkey=RegOpenKey(@REGMACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths")
  82.          mspaintexe=RegQueryValue(rkey,"MSPAINT.EXE")
  83.          RegCloseKey(rkey)
  84.          Run(mspaintexe,file)
  85.  &Wordpad (text and graphics) ; Modify WORD, RTF, plain text files. Can contain bitmaps, too.
  86.          file = CurrFilePath()
  87.          If !(FileExist(file)) Then file = ""
  88.               Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  89.          rkey=RegOpenKey(@REGMACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths")
  90.          wordpadexe=RegQueryValue(rkey,"WORDPAD.EXE")
  91.          RegCloseKey(rkey)
  92.          Run(wordpadexe,file)
  93.  Win&Edit (text) ; Open file with WinEdit
  94.         f = CurrFilePath()
  95.         If !(FileExist(f)) Then f = ""
  96.         Else If FileExtension(f) == "" Then f = StrCat(f, ".")
  97.         Run(WinEdit, f)
  98.  
  99.      
  100. File Operations
  101.  
  102.  Print (with Notepad)    ;Print text-type file with notepad on default printer
  103.     Run("notepad.exe",strcat("/p ",FileCurrPath())
  104.  Associate        ;Associate this type of file with an application
  105.         a=strlower(FileExtension(CurrentFile()))
  106.         b=AskFileName("Associate %a% files with","C:\","Executable Files|*.exe;*.com;*.bat;*.pif|All Files|*.*|","",1)
  107.     
  108.         rkey=RegOpenKey(@REGCLASSES,"")
  109.         ErrorMode(@OFF)
  110.         RegDeleteKey(rkey,".%a%")
  111.         ErrorMode(@CANCEL)
  112.         RegSetValue(rkey, ".%a%", "%a%_auto_file")
  113.         RegSetValue(rkey,"%a%_auto_file\shell\open\command",strcat('"',b,'" "%%1"'))
  114.         RegClosekey(rkey)
  115.  File Attributes    ;View file attributes
  116.         files = FileItemize("")
  117.         numfiles = ItemCount(files,@TAB)
  118.         While numfiles == 1
  119.         file = CurrentFile()
  120.         result = FileAttrGet(file)
  121.         If StrLen(file) > 30
  122.              fileindialog = StrSub(file,1,30)
  123.           
  124.              fileindialog = StrCat(fileindialog," ...")
  125.         Else 
  126.              fileindialog = file
  127.         EndIf
  128.      
  129.         readonly = 2
  130.         archive = 2
  131.         system = 2
  132.         hidden = 2
  133.         If StrSub(result,1,1) == "R" Then readonly = "3"
  134.         If StrSub(result,2,1) == "A" Then archive = "3"
  135.         If StrSub(result,3,1) == "S" Then system = "3"
  136.         If StrSub(result,4,1) == "H" Then hidden = "3"
  137.  
  138.                FileAttributesFormat=`WWWDLGED,5.0`
  139.                
  140.                FileAttributesCaption=`File Attributes`
  141.                FileAttributesX=7
  142.                FileAttributesY=25
  143.                FileAttributesWidth=199
  144.                FileAttributesHeight=101
  145.                FileAttributesNumControls=17
  146.                
  147.                FileAttributes01=`110,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`
  148.                FileAttributes02=`42,18,38,DEFAULT,STATICTEXT,DEFAULT,"Read Only"`
  149.                FileAttributes03=`126,18,36,DEFAULT,STATICTEXT,DEFAULT,"System"`
  150.                FileAttributes04=`84,18,36,DEFAULT,STATICTEXT,DEFAULT,"Archive"`
  151.                FileAttributes05=`168,18,36,DEFAULT,STATICTEXT,DEFAULT,"Hidden"`
  152.                FileAttributes06=`56,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1`
  153.                FileAttributes07=`2,54,36,DEFAULT,STATICTEXT,DEFAULT,"On"`
  154.                FileAttributes08=`2,36,36,DEFAULT,STATICTEXT,DEFAULT,"Off"`
  155.                FileAttributes09=`2,4,194,DEFAULT,STATICTEXT,DEFAULT,"Set File Attributes for => %fileindialog% "`
  156.                FileAttributes10=`42,36,36,DEFAULT,RADIOBUTTON,readonly,"",2`
  157.                FileAttributes11=`42,54,36,DEFAULT,RADIOBUTTON,readonly,"",3`
  158.                FileAttributes12=`166,54,36,DEFAULT,RADIOBUTTON,hidden,"",3`
  159.                FileAttributes13=`84,36,36,DEFAULT,RADIOBUTTON,archive,"",2`
  160.                FileAttributes14=`84,54,36,DEFAULT,RADIOBUTTON,archive,"",3`
  161.                FileAttributes15=`166,36,36,DEFAULT,RADIOBUTTON,hidden,"",2`
  162.                FileAttributes16=`126,36,36,DEFAULT,RADIOBUTTON,system,"",2`
  163.                FileAttributes17=`126,54,36,DEFAULT,RADIOBUTTON,system,"",3`
  164.                
  165.                ButtonPushed=Dialog("FileAttributes")
  166.  
  167.  
  168.  
  169.            Select buttonpushed
  170.           
  171.                Case 0
  172.                     Break
  173.                     
  174.                Case 1
  175.  
  176.                     first = ""
  177.                     second = ""
  178.                     third = ""
  179.                     fourth = ""
  180.                     If readonly == 2 Then first = "r"
  181.                     If archive == 2 Then second = "a"
  182.                     If system == 2 Then third = "s"
  183.                     If hidden == 2 Then fourth = "h"
  184.                     If readonly == 3 Then first = "R"
  185.                     If archive == 3 Then second = "A"
  186.                     If system == 3 Then third = "S"
  187.                     If hidden == 3 Then fourth = "H"
  188.  
  189.                     
  190.                     
  191.                     
  192.                     attributes = StrCat( first, second, third, fourth )
  193.                     FileAttrSet(file, attributes)
  194.                     break
  195.            End Select
  196.                 
  197.  
  198.      Exit
  199.      EndWhile
  200.  
  201.      ;Set Attributes: Selected Files
  202.  
  203.      displayfiles = files
  204.      readonly = 1
  205.      archive = 1
  206.      system = 1
  207.      hidden = 1
  208.                AttribFormat=`WWWDLGED,5.0`
  209.                
  210.                AttribCaption=`Attributes`
  211.                AttribX=6
  212.                AttribY=25
  213.                AttribWidth=201
  214.                AttribHeight=101
  215.                AttribNumControls=22
  216.                
  217.                Attrib01=`110,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`
  218.                Attrib02=`42,18,38,DEFAULT,STATICTEXT,DEFAULT,"Read Only"`
  219.                Attrib03=`126,18,36,DEFAULT,STATICTEXT,DEFAULT,"System"`
  220.                Attrib04=`84,18,36,DEFAULT,STATICTEXT,DEFAULT,"Archive"`
  221.                Attrib05=`168,18,36,DEFAULT,STATICTEXT,DEFAULT,"Hidden"`
  222.                Attrib06=`2,34,38,DEFAULT,STATICTEXT,DEFAULT,"No Change"`
  223.                Attrib07=`2,70,36,DEFAULT,STATICTEXT,DEFAULT,"On"`
  224.                Attrib08=`2,52,36,DEFAULT,STATICTEXT,DEFAULT,"Off"`
  225.                Attrib09=`42,34,36,DEFAULT,RADIOBUTTON,readonly,"",1`
  226.                Attrib10=`42,52,36,DEFAULT,RADIOBUTTON,readonly,"",2`
  227.                Attrib11=`42,70,36,DEFAULT,RADIOBUTTON,readonly,"",3`
  228.                Attrib12=`84,34,36,DEFAULT,RADIOBUTTON,archive,"",1`
  229.                Attrib13=`84,52,36,DEFAULT,RADIOBUTTON,archive,"",2`
  230.                Attrib14=`84,70,36,DEFAULT,RADIOBUTTON,archive,"",3`
  231.                Attrib15=`126,34,36,DEFAULT,RADIOBUTTON,system,"",1`
  232.                Attrib16=`126,52,36,DEFAULT,RADIOBUTTON,system,"",2`
  233.                Attrib17=`126,70,36,DEFAULT,RADIOBUTTON,system,"",3`
  234.                Attrib18=`168,34,36,DEFAULT,RADIOBUTTON,hidden,"",1`
  235.                Attrib19=`168,52,36,DEFAULT,RADIOBUTTON,hidden,"",2`
  236.                Attrib20=`168,70,36,DEFAULT,RADIOBUTTON,hidden,"",3`
  237.                Attrib21=`58,2,130,DEFAULT,STATICTEXT,DEFAULT,"Set Attributes for Selected Files"`
  238.                Attrib22=`56,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1`
  239.                
  240.                ButtonPushed=Dialog("Attrib")
  241.                
  242.  
  243.  
  244.  
  245.           Select buttonpushed
  246.           
  247.                Case 0
  248.                     Break
  249.                     
  250.                Case 1
  251.  
  252.                     first = ""
  253.                     second = ""
  254.                     third = ""
  255.                     fourth = ""
  256.                     If readonly == 2 Then first = "r"
  257.                     If archive == 2 Then second = "a"
  258.                     If system == 2 Then third = "s"
  259.                     If hidden == 2 Then fourth = "h"
  260.                     If readonly == 3 Then first = "R"
  261.                     If archive == 3 Then second = "A"
  262.                     If system == 3 Then third = "S"
  263.                     If hidden == 3 Then fourth = "H"
  264.  
  265.                     
  266.                     
  267.                     
  268.                     attributes = StrCat( first, second, third, fourth )
  269.                     FileAttrSet(files, attributes)
  270.                     break
  271.            End Select
  272.       Exit                              
  273.  
  274.  
  275.  DOS &Copy  ; Like the good, old, DOS COPY command.
  276.        s = StrTrim(FileItemize(""))
  277.        s=StrReplace(s,@tab,"|")
  278.        If s == "" Then Message("Copy Error", "No files selected")
  279.        Then Exit
  280.        If ItemCount(s, "|") == 1 Then t = s
  281.        Else t = ""
  282.        t = AskLine("Copy", StrCat(s, @CRLF, @CRLF, "to"), t)
  283.        If t == "" Then Message("Copy Error", "Cannot copy to null file name")
  284.                Then Exit
  285.        FileCopy(s, t, @TRUE)
  286.  
  287.  DOS &Rename  ;Like the good, old DOS RENAME command.
  288.        s = StrTrim(FileItemize(""))
  289.        s=StrReplace(s,@tab,"|")
  290.        If s == "" Then Message("Rename Error", "No files selected")
  291.        Then Exit
  292.        If ItemCount(s, "|") == 1 Then t = s
  293.        Else t = ""
  294.        t = AskLine("Rename", StrCat(s, @CRLF, @CRLF, "to"), t)
  295.        If t == "" Then Message("Rename Error", "Cannot rename to null file name")
  296.                   Then Exit
  297.        FileRename(s, t)
  298.  
  299.   
  300. Clipboard Tricks ; Copies just the filenames to the clipboard
  301.  FileName(s) to Clipboard ; Just the filenames
  302.     a=FileItemize("")
  303.         a=ItemSort(a,@tab)
  304.         a=strreplace(a,@TAB,@CRLF)
  305.     ClipPut(a)
  306.         Display(2,"Filenames placed on Clipboard",a)
  307.  Path and FileName(s) to Clipboard ; Copies filenames with full paths to the Clipboard
  308.         a=FileItemize("")
  309.         a=ItemSort(a,@TAB)
  310.     a=strcat(@TAB,StrSub(a,1,strlen(a)-1))
  311.     b=DirGet()
  312.     a=StrSub(StrReplace(a,@TAB,strcat(@TAB,b)),2,-1)
  313.     a=StrReplace(a,@TAB,@CRLF)
  314.     ClipPut(a)
  315.         Display(2,"Full path filenames placed on Clipboard",a)
  316.  Path to Clipboard   ; Copies just the path to the clipboard
  317.         a=DirGet()
  318.         ClipPut(a)
  319.         Display(2,"Path placed on Clipboard",a)
  320.     
  321.     
  322.  _Run Clipboard Viewer   ; Lets you see what is on the clipboard
  323.     Run("clipbd.exe","")
  324.  
  325.  
  326. WIL Interactive
  327.  Execute a function
  328.         call("%homedir%wwwmenu95.wil","CMDSTACK NEWCMD")
  329.  _Load WIL Help File
  330.     WinHelp(strcat(wbdir,"Windows Interface Language.hlp"),"CONTENTS","")     
  331.       
  332.  
  333.  
  334.      
  335. _Edit File Menus ; Modify WinBatch FileMenus here 
  336.  Edit menu for this filetype  ; Edit menus for files with a specific file extension.
  337.         b=strupper(FileExtension(CurrentFile()))
  338.         a=IniReadPvt("Menus",b,"*NONE*",inifile)
  339.         if a=="*NONE*" then a=strcat("FileMenu for %b% files",".mnw")
  340.         if FilePath(a)=="" then a=strcat(HomeDir,a)
  341.         ;Message(a,FileExist(a))
  342.         if !(FileExist(a))
  343.                 c=AskYesNo("Please note:","The menu file for the %b% filetype does not exist.  Would you like to start a new one?")
  344.                 if c==@NO then exit
  345.                 c=               "; WinBatch FileMenu for %b% filetype%@CRLF%"
  346.                 c=strcat(c,@CRLF,"; This is a sample menu file to help you get started")
  347.                 c=strcat(c,@CRLF,"; writing your very own Winbatch FileMenu menus.  It is")
  348.                 c=strcat(c,@CRLF,"; really not too bad.  WinBatch is a simple programming")
  349.                 c=strcat(c,@CRLF,"; language.  You can find out just about all you need to")
  350.                 c=strcat(c,@CRLF,"; know from the Windows Interface Language help file or")
  351.                 c=strcat(c,@CRLF,"; the manual.  Check out the section on Menu Files,")
  352.                 c=strcat(c,@CRLF,"; the WIL Tutorial and the WIL Function Reference.")
  353.  
  354.                 c=strcat(c,@CRLF,@CRLF,'Standalone menu item            ; Sample menu item')
  355.                 c=strcat(c,@CRLF,      '        Message("Hello","There")')
  356.                 c=strcat(c,@CRLF,@CRLF,'Top Level menu item')
  357.                 c=strcat(c,@CRLF,      ' Selected File is               ; Shows currently selected file')
  358.                 c=strcat(c,@CRLF,      '        a=CurrFilePath()')
  359.                 c=strcat(c,@CRLF,      '        Message("Selected File is",a)')
  360.                 c=strcat(c,@CRLF,      ' Run Calculator                 ; Sample Run function')
  361.                 c=strcat(c,@CRLF,      '        Run("calc.exe","")')
  362.                 c=strcat(c,@CRLF,      ' Run Notepad on selected file   ; Sample Run function with filename')
  363.                 c=strcat(c,@CRLF,      '        a=CurrFilePath()')
  364.                 c=strcat(c,@CRLF,      '        Run("notepad.exe",a)')
  365.  
  366.                 c=strcat(c,@CRLF,@CRLF,'; Note: You may want to delete this menu item if you edit this file')
  367.                 c=strcat(c,@CRLF,      ' _Delete this sample menu file  ; Deletes this menu file')
  368.  
  369.                 c=strcat(c,@CRLF,      '        inifile=strcat(DirWindows(0),"FileMenu.ini")')
  370.                 c=strcat(c,@CRLF,      '        if !FileExist(inifile) then inifile=strcat(homedir,"FileMenu.ini")')
  371.  
  372.  
  373.                 c=strcat(c,@CRLF,      '        b=strupper(FileExtension(CurrentFile()))')
  374.                 c=strcat(c,@CRLF,      '        a=IniReadPvt("Menus",b,"*NONE*",inifile)')
  375.                 c=strcat(c,@CRLF,      '        if a=="*NONE*" then a=strcat("FileMenu for %b% files",".mnw")')
  376.                 c=strcat(c,@CRLF,      '        if FilePath(a)=="" then a=strcat(HomeDir,a)')
  377.                 c=strcat(c,@CRLF,      '        c=AskYesNo("Are you sure you wish to delete this menu file",a)')
  378.                 c=strcat(c,@CRLF,      '        if c==@YES')
  379.                 c=strcat(c,@CRLF,      '           IniDeletePvt("Menus",b,inifile)')
  380.                 c=strcat(c,@CRLF,      '           FileDelete(a)')
  381.                 c=strcat(c,@CRLF,      '        endif')
  382.  
  383.  
  384.  
  385.  
  386.                 c=strcat(c,@CRLF)
  387.                 fh=FileOpen(a,"WRITE")
  388.                 FileWrite(fh,c)
  389.                 FileClose(fh)
  390.                 iniwritepvt("Menus",b,a,inifile)
  391.                 drop(c)
  392.                 
  393.         endif
  394.         Run(Editor,a)
  395.  ;Edit the Miscellaneous File Menu     ; Edit menus for files with unrecognized extensions
  396.  ;       a=IniReadPvt("FileMenu","DefaultMenu",defaultmenu,inifile)
  397.  ;       a=strcat(HomeDir,a)
  398.  ;       Run(Editor,a)
  399.  Edit menu for all filetypes      ; Edit global menu for all files 
  400.         a=IniReadPvt("FileMenu","CommonMenu",commonmenu,inifile)
  401.         a=strcat(HomeDir,a)
  402.         Run(Editor,a) 
  403.  _Load WIL Help File
  404.     WinHelp(strcat(wbdir,"Windows Interface Language.hlp"),"CONTENTS","")     
  405.  
  406.  _About WinBatch FileMenu  ; Software from Wilson WindowWare
  407.         About()           
  408.            
  409.